import { IPSOne2OneObjDEField } from './ipsone2-one-obj-defield';
import { PSDEFieldImpl } from './psdefield-impl';
import { IPSSysDynaModel } from '../../dynamodel/ipssys-dyna-model';

export class PSOne2OneObjDEFieldImpl extends PSDEFieldImpl implements IPSOne2OneObjDEField {
  protected refpssysdynamodel: IPSSysDynaModel | null = null;

  getRefPSSysDynaModel(): IPSSysDynaModel | null {
    if (this.refpssysdynamodel != null) return this.refpssysdynamodel;
    const value = this.M.getRefPSSysDynaModel;
    if (value == null) {
      return null;
    }
    this.refpssysdynamodel = this.getPSModel4('dynamodel.IPSSysDynaModel', value, 'getRefPSSysDynaModel') as IPSSysDynaModel;
    return this.refpssysdynamodel;
  }

  get refPSSysDynaModel(): IPSSysDynaModel | null {
    return this.getRefPSSysDynaModel();
  }

  getRefPSSysDynaModelMust(): IPSSysDynaModel {
    const value = this.getRefPSSysDynaModel();
    if (value == null) {
      throw new Error('未指定引用动态模型');
    }
    return value;
  }

  get cls(): string {
    return 'PSOne2OneObjDEFieldImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.defield.IPSOne2OneObjDEField') return true;
    return super.instanceof(cls);
  }
}
